<template>
	<el-menu default-active="2" class="el-menu-vertical-demo">
		<el-sub-menu index="1">
			<template #title>
				<el-icon>
					<CirclePlus />
				</el-icon>
				<span>我的信息</span>
			</template>
			<el-menu-item index="1-1">账户管理</el-menu-item>
			<el-menu-item index="1-2" @click="addTab('EMAILLIST')">邮件信息</el-menu-item>
			<el-menu-item index="1-3" @click="test">测试方法</el-menu-item>
		</el-sub-menu>
		<el-sub-menu index="2">
			<template #title>
				<el-icon>
					<CirclePlus />
				</el-icon>
				<span>搜索添加</span>
			</template>
			<el-menu-item index="2-1" @click="addTab('FINDFRIEND')">搜索好友</el-menu-item>
			<el-menu-item index="2-2">搜索群聊</el-menu-item>
		</el-sub-menu>
	</el-menu>
</template>

<script setup>
	import {
		getCurrentInstance,
	} from 'vue';

	let {
		proxy
	} = getCurrentInstance();

	let test = () => {
		proxy.$axios.post("/email/getEmails").then((rls) => {
			console.log(rls);
		}).catch((error) => {
			ElNotification({
				title: '错误!',
				message: '用户登录失败，请检查网络连接！',
				type: 'error',
				offset: 100,
				duration: 3000,
			})
		});
	}


	import useUser from "@/store/user.js"
	import useFriend from "@/store/friend.js"
	import useTabUnit from "@/store/tabUnit.js"

	let userData = useUser();
	let FriendData = useFriend();
	let tabUnitData = useTabUnit();



	let addTab = (type) => {

		switch (type) {
			case "FINDFRIEND":
				tabUnitData.createInstance(type, {
					title: '搜索好友',
					name: 'FINDFRIEND'
				})
				break;
				case "EMAILLIST":
				tabUnitData.createInstance(type, {
					title: '邮件信息',
					name: 'EMAILLIST'
				})
				break;
			default:
				break;
		}
	}
</script>